#include "drv_cfg.h"

#ifndef __MON_CFG_H__
#define __MON_CFG_H__

#ifndef _XTAL_FREQ
#define _XTAL_FREQ    16000000
#endif

#define I2C_MON_CLOCK_FREQ    50000
#define I2C_MON_DELAY_CONT    _XTAL_FREQ/I2C_MON_CLOCK_FREQ
#define I2C_MON_DELAY_US     1000000/I2C_MON_CLOCK_FREQ
#define I2C_MON_NOACK_COUNT    10

#define HIGH    1
#define LOW    0
#define TRUE    1
#define FALSE    0
#define ACK    TRUE
#define NOACK    FALSE  
#define SDA 1
#define SCL 0 
#define IO_INPUT    1
#define IO_OUTPUT    0

//data struct
typedef enum
{
    I2C_CHANNEL_A = 0,
    I2C_CHANNEL_B,
    I2C_CHANNEL_C,
    I2C_CHANNEL_D,
    I2C_CHANNEL_E,
    I2C_CHANNEL_F,
    I2C_CHANNEL_G,
    I2C_CHANNEL_H,
    I2C_CHANNEL_NUMS
}I2C_Channel;

typedef enum
{
    I2C_STATUS_Success = 0,
    I2C_STATUS_NoAck,
    I2C_STATUS_Pending,
    I2C_STATUS_Abort,
    I2C_STATUS_TimeOut,
    I2C_STATUS_UnKnown
}I2C_Status;

typedef struct
{
    I2C_Channel channel;
    I2C_Status stat;
    //unsigned char delay;
    //unsigned char noack_timeout_count;
}I2C_Device;

typedef enum
{
    I2C_MODE_Normal = 0,
    I2C_MODE_SkipStop,
    I2C_MODE_SkipStart,
    I2C_MODE_DataOnly
}I2C_Mode;

void I2CMasterMon_Init(void);
void I2C_master_rw_synchronous(I2C_Device dev, unsigned char addr, unsigned char *pdata, unsigned char length, I2C_Mode mode);

#endif